package com.tuxing.draa_data.pojo.center;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.tuxing.draa_data.dto.CnJournalExcelDto;
import com.tuxing.draa_data.pojo.CnkiYsh;
import com.tuxing.draa_data.pojo.DraaTemporaryBook;
import com.tuxing.draa_data.pojo.db.*;
import com.tuxing.draa_data.pojo.subject.YshScoupsJournalData;
import com.tuxing.draa_data.pojo.subject.YshWosExcelData;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 元数据基础信息表-期刊
 * </p>
 *
 * @author yuanshihang
 * @since 2021-11-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class NewDcBibliographyPeri implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 元数据记录号
     */
    @TableId(value = "RECORD_ID", type = IdType.ASSIGN_ID)
    private Long recordId;

    /**
     * 元数据类型
     */
    @TableField("MD_TYPE")
    private String mdType;

    /**
     * 国别
     */
    @TableField("COUNTRY_CODE")
    private String countryCode;

    /**
     * 语种
     */
    @TableField("LANG_CODE")
    private Integer langCode;

    /**
     * 题名
     */
    @TableField("TITLE")
    private String title;

    /**
     * 题名译名
     */
    @TableField("TRANS_TITLE")
    private String transTitle;

    /**
     * 其他、原期刊名称、并列题名
     */
    @TableField("ALTERNATE_TITLE")
    private String alternateTitle;

    /**
     * 责任者
     */
    @TableField("AUTHOR")
    private String author;

    /**
     * 责任者译名
     */
    @TableField("AUTHOR_EN")
    private String authorEn;

    /**
     * 出版社
     */
    @TableField("PUBLISHER")
    private String publisher;

    /**
     * 原出版社
     */
    @TableField("OLD_PUBLISHER")
    private String oldPublisher;

    /**
     * 印刷ISSN
     */
    @TableField("P_ISSN")
    private String pIssn;

    /**
     * 电子ISSN
     */
    @TableField("O_ISSN")
    private String oIssn;

    /**
     * 国内刊号
     */
    @TableField("PERI_CN_NO")
    private String periCnNo;


    @TableField("DRAA_JID")
    private String draaJid;

    /**
     * 对应超星期刊表中的mag_id
     */
    @TableField("mag_id")
    private String magId;

    /**
     * 匹配类型 1 TITLE和P_ISSN 匹配 2 P_ISSN 匹配 3 O_ISSN 匹配 4 TITLE 匹配 5 TITLE匹配 但P_ISSN和O_ISSN不为空
     */
    @TableField("DATA_TYPE")
    private Integer dataType;


    /**
     * 创建人
     */
    @TableField("CREATE_BY")
    private Integer createBy;

    /**
     * 创建时间
     */
    @TableField("CREATE_DATE")
    private LocalDateTime createDate;

    /**
     * 更新人
     */
    @TableField("UPDATE_BY")
    private Integer updateBy;

    /**
     * 更新时间
     */
    @TableField("UPDATE_DATE")
    private LocalDateTime updateDate;

    @TableField("SOURCE")
    private Integer source;

    public void create(DraaTemporaryBook noRepeatOne, Integer dataTypeLang) {
        this.mdType = dataTypeLang == 1 ? "USMARC" : "CNMARC";
        this.langCode = dataTypeLang;
        this.title = noRepeatOne.getTitle();
        this.transTitle = noRepeatOne.getChineseTitle();
        this.publisher = noRepeatOne.getPublish();
        this.pIssn = noRepeatOne.getPIssn();
        if (dataTypeLang == 3) {
            this.periCnNo = noRepeatOne.getEIsbn();
        } else {
            this.oIssn = noRepeatOne.getEIssn();
        }
        this.draaJid = noRepeatOne.getErId();

        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
        this.createDate = LocalDateTime.now();
        this.createBy = -1;
    }

    public void createByWos(YshWosExcelData yshWosExcelData) {
        this.mdType = "DCTERMS";
        this.langCode = 1;
        this.title = yshWosExcelData.getTitle();
        this.publisher = yshWosExcelData.getPublisherName();
        this.pIssn = yshWosExcelData.getPIssn();
        this.oIssn = yshWosExcelData.getEIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByScoups(YshScoupsJournalData scoupsJournal) {
//        this.recordId = recordId;
        this.mdType = "DCTERMS";
//        this.countryCode = countryCode;
        this.langCode = 1;
        this.title = scoupsJournal.getTitle();
//        this.transTitle = transTitle;
//        this.alternateTitle = alternateTitle;
//        this.author = author;
//        this.authorEn = authorEn;
//        this.publisher = publisher;
//        this.oldPublisher = oldPublisher;
        this.pIssn = scoupsJournal.getPrintIssn();
        this.oIssn = scoupsJournal.getEIssn();
//        this.periCnNo = periCnNo;
//        this.draaJid = draaJid;
//        this.magId = magId;
//        this.dataType = dataType;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByCnki(CnJournalExcelDto cnJournalExcelDto) {
        this.mdType = "DCTERMS";
        this.countryCode = "CN";
        if (cnJournalExcelDto.getLang().equals("中文")) {
            this.langCode = 2;
        } else {
            this.langCode = 1;
        }
        this.title = cnJournalExcelDto.getTitle();
        this.transTitle = cnJournalExcelDto.getT_title();
        this.alternateTitle = cnJournalExcelDto.getO_title();
//        this.author = cnJournalExcelDto.get;
//        this.authorEn = authorEn;
        this.publisher = cnJournalExcelDto.getPublisher();
//        this.oldPublisher = oldPublisher;
        this.pIssn = cnJournalExcelDto.getIssn();
//        this.oIssn = oIssn;
        if (cnJournalExcelDto.getLang().equals("中文")) {
            this.periCnNo = cnJournalExcelDto.getCn();
        }
//        this.draaJid = draaJid;
//        this.magId = magId;
//        this.dataType = dataType;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByDcPeri(NewDcPeri newDcPeri) {
//        this.mdType = mdType;
//        this.countryCode = countryCode;
//        this.langCode = newDcPeri.getChoren();
//        this.title = newDcPeri.getMagName();
//        this.transTitle = newDcPeri.get;
//        this.alternateTitle = alternateTitle;
//        this.author = author;
//        this.authorEn = authorEn;
//        this.publisher = publisher;
//        this.oldPublisher = oldPublisher;
//        this.pIssn = newDcPeri.getIssn();
//        this.oIssn = oIssn;
//        this.periCnNo = newDcPeri.getCn();
        this.magId = newDcPeri.getMagId();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByCnki(CnkiYsh cnJournalExcelDto) {

        this.countryCode = "CN";
        if (cnJournalExcelDto.getLang().equals("中文")) {
            this.langCode = 3;
            this.mdType = "DCTERMS";
        } else {
            this.langCode = 1;
            this.mdType = "DCTERMS";
        }
        this.title = cnJournalExcelDto.getName();
//        this.transTitle = cnJournalExcelDto.getT_title();
//        this.alternateTitle = cnJournalExcelDto.getO_title();
////        this.author = cnJournalExcelDto.get;
////        this.authorEn = authorEn;
//        this.publisher = cnJournalExcelDto.getPublisher();
//        this.oldPublisher = oldPublisher;
        this.pIssn = cnJournalExcelDto.getIssn();
//        this.oIssn = oIssn;
        if (cnJournalExcelDto.getLang().equals("中文")) {
            this.periCnNo = cnJournalExcelDto.getCn();
        }
//        this.draaJid = draaJid;
//        this.magId = magId;
//        this.dataType = dataType;
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByWeipu(Weipu20220629 weipu20220629) {
        this.mdType = "CNMARC";
        this.countryCode = "CN";
        this.langCode = 3;
        this.title = weipu20220629.getName();
        this.publisher = weipu20220629.getSponsor();
        this.alternateTitle = weipu20220629.getOldName();
        this.pIssn = weipu20220629.getIssn();
        this.periCnNo = weipu20220629.getCn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByAdis(Adis20220630 adis20220630) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = adis20220630.getTitle();
        this.pIssn = adis20220630.getPrintIssn();
        this.oIssn = adis20220630.getElectrionicIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByAdis2(Adis20220630001 adis20220630001) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = adis20220630001.getTitle();
        this.pIssn = adis20220630001.getISSNprint();
        this.oIssn = adis20220630001.getISSNelectronic();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByArt(Art20220701 art20220701) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = art20220701.getPublicationName();
        this.pIssn = art20220701.getIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByBsc(Bsc20220701 bsc20220701) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = bsc20220701.getPublicationName();
        this.pIssn = bsc20220701.getIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByBsp(Bsp20220701 bsp20220701) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = bsp20220701.getPublicationName();
        this.pIssn = bsp20220701.getIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByBsu(Bsu20220701 bsu20220701) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = bsu20220701.getPublicationName();
        this.pIssn = bsu20220701.getIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByCinahk(Cinahk20220701 cinahk20220701) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = cinahk20220701.getPublicationName();
        this.pIssn = cinahk20220701.getIssn();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByEmbase(Embase20220704 embase20220704) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = embase20220704.getEmbasejournaltitles();
        this.alternateTitle = embase20220704.getAbbreviatedtitle();
        this.pIssn = embase20220704.getIssn();
        this.publisher = embase20220704.getPublisher();
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }


    public void createByRsc(RscJournal20220706 rsc) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = rsc.getName();
        this.pIssn = rsc.getIssn();
        this.publisher = "Royal Society of Chemistry";
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }

    public void createByWorldScientific(WorldScientific20220706 scientific) {
        this.mdType = "USMARC";
        this.countryCode = "US";
        this.langCode = 1;
        this.title = scientific.getName();
        this.alternateTitle = scientific.getDName();
        this.transTitle = scientific.getCnName();
        this.pIssn = scientific.getIssn();
        this.oIssn = scientific.getEIssn();
        this.publisher = "WorldSciNet";
        this.createBy = -1;
        this.createDate = LocalDateTime.now();
        this.updateBy = -1;
        this.updateDate = LocalDateTime.now();
    }
}
